#include<bits/stdc++.h>
using namespace std;
const int NN=2e5+4,P=1e9+7;
vector<int>g[NN],f[NN];
int p2[NN],last[NN],res[NN];
void dfs(int u)
{
	for(auto v:g[u])
	{
		dfs(v);
		if(f[v].size()>f[u].size())
			swap(f[u],f[v]);
	}
	for(auto v:g[u])
		for(int i=f[u].size()-1,j=f[v].size()-1;~j;i--,j--)
		{
			if(last[i]!=u)
			{
				last[i]=u;
				res[i]=(1-f[u][i]+P)%P;
			}
			f[u][i]=(1ll*f[u][i]*(1-f[v][j]+P)%P+1ll*res[i]*f[v][j]%P)%P;
			res[i]=1ll*res[i]*(1-f[v][j]+P)%P;
		}
	f[u].push_back((P+1)/2);
}
int main()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	int n;
	scanf("%d",&n);
	n++;
	for(int i=2;i<=n;i++)
	{
		int fa;
		scanf("%d",&fa);
		fa++;
		g[fa].push_back(i);
	}
	dfs(1);
	int ans=0;
	for(int i=0;i<f[1].size();i++)
		ans=(ans+f[1][i])%P;
	for(int i=1;i<=n;i++)
		ans=2ll*ans%P;
	printf("%d",ans);
	return 0;
} 
